package com.test;

/*
class Person<T> {
    private T info;

    public Person(T info) {
        this.info = info;
    }

    public T getInfo() {
        return info;
    }
}

public class Example02 {
    public static void main(String[] args) {
        //创建Person对象,传入String类型的类型实参
        Person<?> person = new Person<String>("M1");
        System.out.println(person.getInfo() + "..." + person.getInfo().getClass());
        //创建Person对象,传入Integer类型的类型实参
        person = new Person<Integer>(66);
        System.out.println(person.getInfo() + "..." + person.getInfo().getClass());
    }

}
*/


/*
import java.util.ArrayList;
import java.util.Collection;

public class Example02 {
    //设定类型通配符的上限,此时传入的类型实参必须是Number类型或者其子类
    public static void getElement(Collection<? extends Number> coll) {
    }

    public static void main(String[] args) {
        //创建Collection对象,传入Number类型的类型实参
        Collection<Number> list1 = new ArrayList<Number>();
        //创建Collection对象,传入Integer类型的类型实参
        Collection<Integer> list2 = new ArrayList<Integer>();
        //创建Collection对象,传入String类型的类型实参
        Collection<String> list3 = new ArrayList<String>();
        getElement(list1);
        getElement(list2);
        //getElement(list3);这里报错
        //'getElement(java.util.Collection<? extends java.lang.Number>)' in 'com.test.Example02' cannot be applied to '(java.util.Collection<java.lang.String>)'
    }
}

 */


import java.util.ArrayList;
import java.util.Collection;


public class Example02 {
    // 设定类型通配符的下限，此时传入的类型实参，必须是Number类型或者Number类型的父类
    public static void getElement(Collection<? super Number> coll) {
    }

    public static void main(String[] args) {
        //创建Collection对象,传入Number类型的类型对象
        Collection<Number> list1 = new ArrayList<Number>();
        //创建Collection对象,传入Object类型的类型对象
        Collection<Object> list2 = new ArrayList<Object>();
        //创建Integer对象,传入Integer类型的类型对象
        Collection<Integer> list3 = new ArrayList<Integer>();
        getElement(list1);
        getElement(list2);
//        getElement(list3);
    //'getElement(java.util.Collection<? super java.lang.Number>)' in 'com.test.Example02' cannot be applied to '(java.util.Collection<java.lang.Integer>)'
    }

}
